package com.cse587.gae.entities;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Element;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class Country {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
	@Persistent
	private String fullName;
	@Persistent
	private int uncode;
	@Persistent
	private String codeISO3;
	@Persistent
	private double maxLat;
	@Persistent
	private double minLat;
	@Persistent
	private double maxLong;
	@Persistent
	private double minLong;
	@Persistent
	private String capital;
	@Persistent
	private double capitalLat;
	@Persistent
	private double capitalLong;
	
	
	@Persistent(mappedBy = "country")
	@Element( dependent = "true" )
	private List<LandArea> landArea;

	@Persistent(mappedBy = "country")
	@Element( dependent = "true" )
	private List<Population> population;
	
	@Persistent(mappedBy = "country")
	@Element( dependent = "true" )
	private List<GDP> gdp;
	
	@Persistent(mappedBy = "country")
	@Element( dependent = "true" )
	private List<HDI> hdi;
	
	@Persistent
	private Set<String> borders;
	
	@Persistent
	private Set<String> alternativeName;
	
	public Country(){
		landArea = new ArrayList<LandArea>();
		population = new ArrayList<Population>();
		gdp = new ArrayList<GDP>();
		hdi = new ArrayList<HDI>();
		borders = new HashSet<String>();
		alternativeName = new HashSet<String>();
	}
	public Country(int id, String fullName, String codeISO3, double maxLat, double minLat,
			double maxLong, double minLong, String capital) {
		super();
		this.fullName = fullName;
		this.codeISO3 = codeISO3;
		this.maxLat = maxLat;
		this.minLat = minLat;
		this.maxLong = maxLong;
		this.minLong = minLong;
		this.capital = capital;
		
		landArea = new ArrayList<LandArea>();
		population = new ArrayList<Population>();
		gdp = new ArrayList<GDP>();
		hdi = new ArrayList<HDI>();
		borders = new HashSet<String>();
		alternativeName = new HashSet<String>();
	}
	
	public Key getKey() {
		return key;
	}
	public void setKey(Key key) {
		this.key = key;
	}
	public int getUncode() {
		return uncode;
	}
	public void setUncode(int uncode) {
		this.uncode = uncode;
	}
	public String getFullName() {
		return fullName;
	}
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}
	public String getCodeISO3() {
		return codeISO3;
	}
	public void setCodeISO3(String codeISO3) {
		this.codeISO3 = codeISO3;
	}
	public double getMaxLat() {
		return maxLat;
	}
	public void setMaxLat(double maxLat) {
		this.maxLat = maxLat;
	}
	public double getMinLat() {
		return minLat;
	}
	public void setMinLat(double minLat) {
		this.minLat = minLat;
	}
	public double getMaxLong() {
		return maxLong;
	}
	public void setMaxLong(double maxLong) {
		this.maxLong = maxLong;
	}
	public double getMinLong() {
		return minLong;
	}
	public void setMinLong(double minLong) {
		this.minLong = minLong;
	}
	public String getCapital() {
		return capital;
	}
	public void setCapital(String capital) {
		this.capital = capital;
	}
	
	public List<LandArea> getLandArea() {
		return landArea;
	}
	public void setLandArea(List<LandArea> landArea) {
		this.landArea = landArea;
	}
	public List<Population> getPopulation() {
		return population;
	}
	public void setPopulation(List<Population> populations) {
		this.population = populations;
	}
	public List<GDP> getGdp() {
		return gdp;
	}
	public void setGdp(List<GDP> gdp) {
		this.gdp = gdp;
	}
	public List<HDI> getHdi() {
		return hdi;
	}
	public void setHdi(List<HDI> hdi) {
		this.hdi = hdi;
	}
	public Set<String> getBorders() {
		return borders;
	}
	public void setBorders(Set<String> borderList) {
		this.borders = borderList;
	}
	public Set<String> getAlternativeName() {
		return alternativeName;
	}
	public void setAlternativeName(Set<String> alternativeName) {
		this.alternativeName = alternativeName;
	}
	
    public double getCapitalLat() {
		return capitalLat;
	}
	public void setCapitalLat(double capitalLat) {
		this.capitalLat = capitalLat;
	}
	public double getCapitalLong() {
		return capitalLong;
	}
	public void setCapitalLong(double capitalLong) {
		this.capitalLong = capitalLong;
	}
	
	@Override
    public boolean equals(Object obj) {
        return obj instanceof Country && this.key.equals(((Country)obj).getKey());
    }
    @Override
    public int hashCode() {
        return this.key.hashCode();
    }
}
